package queue;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-04-16
 * Time:14:55
 */
public class MyQueue {
    static class Listcode{
        int val;
        Listcode next;
        Listcode()
        {}
        Listcode(int sum)
        {
            this.val=sum;
        }
    }
    Listcode head;
    Listcode tail;
    int size;
    public void myoffer(int num)
    {
        Listcode fw=new Listcode(num);
        if(head==null)
        {
            head=fw;
            tail=fw;
        }
        else{
            tail.next=fw;
            tail=fw;
        }
        size++;
    }
    public void mypoll()
    {
        if(head==null)
        {
            return;
        }
        if(head.next==null)
        {
            head=null;
            tail=null;
        }
        head=head.next;
        size--;
    }
    public int mypeek()
    {
        if(head==null)
        {
            return -1;
        }
        return head.val;
    }
    public  void show()
    {
        Listcode kk=new Listcode();
        kk=head;
        while(kk!=null)
        {
            System.out.print(kk.val);
            kk=kk.next;
        }
        System.out.println();
    }
}
